package karileet.meeting.profile.fragment;

import karileet.meeting.profile.ProfileConf;
import karileet.meeting.profile.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;

public class BeggarFragment extends DialogFragment {
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
	    // Get the layout inflater
	    LayoutInflater inflater = getActivity().getLayoutInflater();
//	    getDialog().setTitle("Notification settings");
//	    builder.setTitle(R.string.volume_title);
	    // Inflate and set the layout for the dialog
	    // Pass null as the parent view because its going in the dialog layout
	    View v = inflater.inflate(R.layout.begger_fragment, null);
	    final ProfileConf state = new ProfileConf(getActivity());
	    final CheckBox cb = (CheckBox) v.findViewById(R.id.checkBox1);
	    builder.setView(v)
	    // Add action buttons
	           .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
	               @Override
	               public void onClick(DialogInterface dialog, int id) {
	            	   if (cb.isChecked()) {
	            		   Log.d(ProfileConf.APP, "Disabling beggar");
	            		   state.setStopBeg(true);
	            	   } else {
	            		   Log.d(ProfileConf.APP, "Dismissing beggar");
	            	   }
	               }
	           });   
	    return builder.create();
	}
}
